function quickSort1(arr) {
  //input your code here
  // for(let i = arr.length; i > 0; i--) {
  //   for(let j = 0; j < arr.length; j++) {
  //     if(arr[j] > arr[j + 1]) {
  //       var tmp = arr[j];
  //       arr[j] = arr[j + 1];
  //       arr[j + 1] = tmp;
  //     }
  //   }
  // }
  arr.sort(function(a, b) {
    return a - b;
  })
  return arr;
}
function generateCases1(length, step) {
  if (step === void 0) { step = 1; }
  var a = [];
  var value = 0;
  for (var i = 0; i < length; i++) {
      a.push(value);
      value += step;
      // console.log('value:' + value);
  }
  // console.log('a:' + a);
  var tmp;
  for (var i = 0; i < length; i++) {
      var f = Math.random() * (length - i);
      // console.log('f:' + f);
      var r = i + Math.floor(f);
      // console.log('r:' + r);
      tmp = a[r];
      // console.log('tmp:' + tmp);
      a[r] = a[i];
      // console.log('a[r]:' + a[r]);
      a[i] = tmp;
      // console.log('a[i]:' + a[i]);
  }
  // console.log('a:' + a);
  return a;  // 28,7,14,21,0,35
}
function checkRes1(arr, step) {
  for (var i = 0; i < arr.length - 1; ++i) {
    // console.log('arr:' + arr[i]);
    // console.log('step:' + step);
    // console.log('arr+1:' + arr[i + 1]);
    if (arr[i] + step !== arr[i + 1]) return false;
  }
  return true;
}
function testQuickSort1() {
  for (var i = 6; i <= 100000; i = i * 2) {
      var randomStep = Math.ceil(Math.random() * 10);
      // console.log('randomStep:' + randomStep);
      // console.log('i:' + i);
      var arr = generateCases1(i, randomStep);
      var start = Date.now();
      var ret = quickSort1(arr);
      var end = Date.now();
      console.log("Quick sort for ".concat(i, " numbers costs ").concat(end - start, "ms"));
      // console.log('bool:' + checkRes(ret, randomStep)); // false
      if (!checkRes1(ret, randomStep)) {
          console.log("Fail");
          return false;
      }
      else {
          console.log("Passed");
      }
  }
  return true;
}
testQuickSort1();
//quickSort([ 60, 66, 90, 30, 96, 42, 6, 84, 0, 24, 18, 54, 48, 78, 102, 36, 72, 12 ])
